<?php
/**
 * @file
 * Implements all form related hooks
 */

/**
 * Implementation of hook_form().
 */
function race_form($node, &$form_state) {
  
  $form['title'] = array(
    '#type' => 'textfield', 
    '#title' => t('Title'), 
    '#required' => TRUE, 
    '#default_value' => !empty($node->title) ? $node->title : '', 
    '#weight' => -5
  );

  $form['race'] = array(
    '#type' => 'fieldset',
    '#title' => t('Race settings'),
    '#weight' => 5,
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => "race_tab",
  ); 
  
  $form['race']['state'] = array(
    '#type' => 'select',
    '#title' => t('Select box'),
    '#default_value' => (isset($node->state) ? $node->state : Constants::$STATE_SIGNUP),
    '#options' => array(
      Constants::$STATE_SIGNUP => t('Signup Phase'),
      Constants::$STATE_ASSIGNMENT => t('Assigned Phase')
    ),
    '#description' => t('Please choose an phase.'),
    '#group' => 'race_tab',
  );
  
  $form['race']['signup'] = array(
    '#type' => 'textarea', 
    '#title' => t('Signup'), 
    '#default_value' => (isset($node->signup) ? $node->signup : Defaults::$SIGNUP),
    '#rows' => 10, 
    '#required' => TRUE,
    '#group' => 'race_tab',
  );
  
  $form['race']['assignment'] = array(
    '#type' => 'textarea', 
    '#title' => t('Assignment'), 
    '#default_value' => (isset($node->assignment) ? $node->assignment : Defaults::$ASSIGNMENT),
    '#rows' => 10, 
    '#required' => TRUE, 
    '#group' => 'race_tab',
    );
  
  $form['race']['config'] = array(
    '#type' => 'textarea', 
    '#title' => t('Config'), 
    '#default_value' => (isset($node->config) ? $node->config : Defaults::$CONFIG),
    '#rows' => 5, 
    '#required' => TRUE,
    '#group' => 'race_tab',
  );

  return $form; 
}

/**
 * Implementation of hook_form().
 */
function race_admin_form($node) {
  
  $form['title'] = array(
    '#type' => 'textfield', 
    '#title' => t('Title'), 
    '#required' => TRUE, 
    '#default_value' => !empty($node->title) ? $node->title : '', 
    '#weight' => -5
  );
  
  $form['race']['state'] = array(
    '#type' => 'select',
    '#title' => t('Select box'),
    '#default_value' => (isset($node->state) ? $node->state : Constants::$STATE_SIGNUP),
    '#options' => array(
      Constants::$STATE_SIGNUP => t('Signup Phase'),
      Constants::$STATE_ASSIGNMENT => t('Assigned Phase')
    ),
    '#description' => t('Please choose an phase.'),
    '#group' => 'race_tab',
  );
  

  return $form; 
}